﻿using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using PrismLearn.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PrismLearn.ViewModels
{
    public class MainViewModel :BindableBase
    {
        private readonly IDialogService dialogService;//创建prism控件里面的Dailog服务

        public DelegateCommand<string> OpanCommand { get;  set; }

       
        public MainViewModel(IDialogService dialogService) {
            OpanCommand = new DelegateCommand<string>(Open);
            this.dialogService = dialogService;
        }

        private void Open(string obj)
        {
            DialogParameters keys = new DialogParameters();
            keys.Add("Title", "弹窗测试");
            dialogService.ShowDialog(obj, keys, callback =>
            {
                if(callback.Result == ButtonResult.OK)
                {
                    string result = callback.Parameters.GetValue<string>("Value");
                }
            });
        }
    }
}
